﻿using Draco.Algorithms;
using Draco.DataStructure;

namespace BusinessEntities
{
    public class MetroNode:ILocatingPoint
    {
        public int ID { get; }
        public string Name { get; }
        public bool IsTerminal { get; }
        public int X { get; }
        public int Y { get; }
        public string GeoHash { get; }
        public D_LinkList<int> Lines { get; }
        
        public D_LinkList<MetroLink> Links { get; private set; }
    
        public MetroNode() { }

        public MetroNode(int id,string name, int x, int y, bool isTerminal, params int[] lines)
        {
            ID = id;
            Name = name;
            IsTerminal = isTerminal;
            X = x;
            Y = y;

            GeoHash = D_GeoHash.GetGeoHash(X, Y);

            Lines = new D_LinkList<int>();
            Links = new D_LinkList<MetroLink>();

            foreach (int i in lines)
            {
                if (i > 0)
                {
                    Lines.Add(i);
                }
            }
        }

        public MetroLink AddMetroLink(MetroLink link)
        {
            Links.Add(link);
            return link;
        }


        public override string ToString()
        {
            return "ID:" + ID + "\tName:" + Name + "\tX:" + X + "\tY" + Y;
        }
    }
}
